<?php 
	require_once('lib/nusoap.php');
    function getdata(){
		 include("connect/connect.php");
		mysql_select_db("vis",$c);
		mysql_query("set names utf8");
        $sql="select min(aid) as minpk,max(aid) as maxpk from admission_last where senddscc <> 1";
		$rs=mysql_query($sql);
		$result = mysql_fetch_array($rs);
		$minpk=$result["minpk"];
		$maxpk=$result["maxpk"];
		$sql = "select aid, hosp, hn, id,prename,name,fname, residence,adate,atime,vaplace,hdate, htime, rdate, rtime, icdcause, vstaward, frelate1, fprename1, fname1, ffname1, fid1, frelate2, fprename2, fname2, ffname2, fid2, frelate3, fprename3, fname3, ffname3, fid3, frelate4, fprename4, fname4, ffname4, fid4, frelate5, fprename5, fname5, ffname5, fid5, frelate6, fprename6, fname6, ffname6, fid6, frelate7, fprename7, fname7, ffname7, fid7, frelate8, fprename8, fname8, ffname8, fid8, frelate9, fprename9, fname9, ffname9, fid9, frelate10, fprename10, fname10, ffname10, fid10, frelate11, fprename11, fname11, ffname11, fid11, frelate12, fprename12, fname12, ffname12, fid12, frelate13, fprename13, fname13, ffname13, fid13, frelate14, fprename14, fname14, ffname14, fid14, frelate15, fprename15, fname15, ffname15, fid15  from admission_last where  aid  between '$minpk' and '$maxpk'  limit 50";
		//echo $sql;
		$rs=mysql_query($sql);
		$str_return="";	//$str_return="code_acc,date_acc,time_acc,plcid_acc,type_acc1,type_acc2,type_acc3,cause,point_xy,point_x,point_y,trans,weapon1,weapon2,weapon3,weapon4,weapon5,weapon6,weapon7,weapon8,num_loss,num_dth,num_wnd,commt;";
		while ($result = mysql_fetch_array($rs)){
		$str_return=$str_return.$result["aid"].",".$result["hosp"].",".$result["hn"].",".$result["id"].",".$result["prename"].",".$result["name"].",".$result["fname"].",".$result["residence"].",".$result["adate"].",".$result["atime"].",".$result["vaplace"].",".$result["hdate"].",".$result["htime"].",".$result["rdate"].",".$result["htime"].",".$result["icdcause"].",".$result["vstaward"].",".$result["frelate1"].",".$result["fprename1"].",".$result["fname1"].",".$result["ffname1"].",".$result["fid1"].",".$result["frelate2"].",".$result["fprename2"].",".$result["fname2"].",".$result["ffname2"].",".$result["fid2"].",".$result["frelate3"].",".$result["fprename3"].",".$result["fname3"].",".$result["ffname3"].",".$result["fid3"].",".$result["frelate4"].",".$result["fprename4"].",".$result["fname4"].",".$result["ffname4"].",".$result["fid4"].",".$result["frelate5"].",".$result["fprename5"].",".$result["fname5"].",".$result["ffname5"].",".$result["fid5"].",".$result["frelate6"].",".$result["fprename6"].",".$result["fname6"].",".$result["ffname6"].",".$result["fid6"].",".$result["frelate7"].",".$result["fprename7"].",".$result["fname7"].",".$result["ffname7"].",".$result["fid7"].",".$result["frelate8"].",".$result["fprename8"].",".$result["fname8"].",".$result["ffname8"].",".$result["fid8"].",".$result["frelate9"].",".$result["fprename9"].",".$result["fname9"].",".$result["ffname9"].",".$result["fid9"].",".$result["frelate10"].",".$result["fprename10"].",".$result["fname10"].",".$result["ffname10"].",".$result["fid10"].",".$result["frelate11"].",".$result["fprename11"].",".$result["fname11"].",".$result["ffname11"].",".$result["fid11"].",".$result["frelate12"].",".$result["fprename12"].",".$result["fname12"].",".$result["ffname12"].",".$result["fid12"].",".$result["frelate13"].",".$result["fprename13"].",".$result["fname13"].",".$result["ffname13"].",".$result["fid13"].",".$result["frelate14"].",".$result["fprename14"].",".$result["fname14"].",".$result["ffname14"].",".$result["fid14"].",".$result["frelate15"].",".$result["fprename15"].",".$result["fname15"].",".$result["ffname15"].",".$result["fid15"].";";
		}
		$tempY=date("Y");
		if($tempY<"2500"){
			$tempY=(int)$tempY+543;
		}
		$datetime_send= $tempY.date("-m-d-H:i");
		$sql="update admission_last set senddscc=1,datetime_send='$datetime_send' where aid between '$minpk' and '$maxpk'";
		//echo "<br>".$sql;
		$rs=mysql_query($sql);
		return $str_return;
	}

	function getAdmission_last($name){ 
		return getdata();
	} 

 	$ws_server = new soap_server;
$ws_server->configureWSDL('getAdmission_lastWSDL', 'http://localhost/dsccmis/datasource_webservice/');
 
$ws_server->register('getAdmission_last',array('name'=>'xsd:string'),array('Admission_last'=>'xsd:string'),'http://localhost/dsccmis/datasource_webservice/','http://localhost/dsccmis/datasource_webservice','rpc','encoded','send Admission_last');

// Use the request try to invoke the service 
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $ws_server->service($HTTP_RAW_POST_DATA); 
//echo getdata();

?> 
